﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Monocle.DataModel;

namespace Monocle.Models
{
    public class PageItemViewModel
    {
        private tPageItem _dto;
        public PageItemViewModel(tPageItem dto)
        {
            _dto = dto;
        }

        public PageItemViewModel()
        {
            _dto = new tPageItem();
        }


        [HiddenInput(DisplayValue = false)]
        public Guid ID
        {
            get { return _dto.PK_tPageItem; }
            set { _dto.PK_tPageItem = value; }
        }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public byte[] Version
        {
            get { return _dto.Version; }
            set { _dto.Version = value; }

        }

        [Required(ErrorMessageResourceName = "Generic_Required", ErrorMessageResourceType = typeof(Resources.Monocle))]
        [Display(Name = "PageItemViewModel_Name", ResourceType = typeof(Resources.Monocle))]
        public String Name
        {
            get { return _dto.Name; }
            set { _dto.Name = value; }
        }

        [Display(Name = "PageItemViewModel_PageOrder", ResourceType = typeof(Resources.Monocle))]
        public int? PageOrder
        {
            get { return _dto.PageOrder; }
            set { _dto.PageOrder = value; }
        }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public Guid FK_tPage
        {
            get { return _dto.FK_tPage; }
            set { _dto.FK_tPage = value; }
        }

        [ScriptIgnore]
        [Display(Name = "PageItemViewModel_Published", ResourceType = typeof(Resources.Monocle))]
        public bool Published
        {
            get { return _dto.Published; }
            set { _dto.Published = value; }
        }

        [ScriptIgnore]
        [Display(Name = "PageItemViewModel_Module", ResourceType = typeof(Resources.Monocle))]
        public int SelectedModule { get; set; }

        public HTMLViewModel HTMLViewModel { get; set; }
        public FacebookViewModel FacebookViewModel { get; set; }

        /// <summary>
        /// Returns the DTO
        /// </summary>
        /// <returns></returns>
        public tPageItem ToDTO()
        {
            return _dto;
        }
    }
}